
import socketserver模块
import json

sk = socketserver模块.socket()
sk.bind(('127.0.0.1', 9001))
sk.listen()
print('*'*20)

while True:
    conn, addr = sk.accept()
    while True:
        msg = conn.recv(1024).decode('utf-8')
        dic = json.loads(msg)
        print('{}:{}'.format(dic['name'], dic['inp']))
        if dic['inp'].upper() == 'Q':
            print('{}已经下线'.format(dic['name']))
            break
        inp = input('>>>')
        conn.send(inp.encode('utf-8'))
        if inp.upper() == 'Q':
            break
    conn.close()
sk.close()
